const wxSubscribeMessageApi = require('../weixin/subscribemessage');
const { timestampConvert } = require('../../module/tool/time');

const templateIds = {
    orderStatusChangeMessage: '{订阅消息id}'
};

async function sendOrderStatusChangeMessage (openId, orderStatus, productInfo, price, time, remark, orderId) {
    const templateId = templateIds.orderStatusChangeMessage;
    const data = {
        phrase6: {
            value: orderStatus
        },
        thing2: {
            value: productInfo
        },
        amount3: {
            value: (price / 100).toFixed(2) + '元'
        },
        time4: {
            value: timestampConvert('yyyy年M月d日 hh:mm', time)
        },
        thing1: {
            value: remark
        }
    };
    return wxSubscribeMessageApi.sendSubscribeMessage(templateId, openId, '/pages/order-center/express-order', data);
}

module.exports = {
    sendOrderStatusChangeMessage
};
